//
//  JMUtilities.m
//  JMangoClientPrototype1
//
//  Created by Huy on 16/10/09.
//  Copyright 2009 JMango. All rights reserved.
//

#import "JMUtilities.h"
#import "vietnameseSlangAppDelegate.h"

@implementation JMUtilities

+ (id) sharedUtilities {
	static id sharedInstance = nil;
	
	if (sharedInstance == nil)
		sharedInstance = [[JMUtilities alloc] init];
	
	return sharedInstance;
}



#pragma mark -
#pragma mark Application's Documents directory


/**
 Returns the path to the application's Documents directory.
 */
+ (id) getSetting:(NSString*)keyName {
	
    if([keyName isEqualToString:@"serviceBaseURL"]){
        NSString * baseURL = [[(vietnameseSlangAppDelegate*)[[UIApplication sharedApplication] delegate] settings] objectForKey:@"serviceBaseURL"];
		return [NSString stringWithFormat:@"%@",baseURL];
    }
    
    if([keyName isEqualToString:@"testURL"]){
        NSString * testURL = [[(vietnameseSlangAppDelegate*)[[UIApplication sharedApplication] delegate] settings] objectForKey:@"testURL"];
		return [NSString stringWithFormat:@"%@",testURL];
    }
    
    if ([keyName isEqualToString:@"clientActivationURL"] ||
		[keyName isEqualToString:@"remoteImageURL"] ||
		[keyName isEqualToString:@"checkMessageURL"] || 
		[keyName isEqualToString:@"syncURL"] || 
		[keyName isEqualToString:@"checkVersionURL"] ||
		[keyName isEqualToString:@"registerURL"])
	{
		NSString * extURL = [[(vietnameseSlangAppDelegate*)[[UIApplication sharedApplication] delegate] settings] objectForKey:keyName];
		NSString * baseURL = [[(vietnameseSlangAppDelegate*)[[UIApplication sharedApplication] delegate] settings] objectForKey:@"serviceBaseURL"];
		return [NSString stringWithFormat:@"%@%@",baseURL,extURL];
	}
	else
	{
		
		id setting = [[(vietnameseSlangAppDelegate*)[[UIApplication sharedApplication] delegate] settings] objectForKey:keyName];
		if(setting)
			return setting;
		else {
			id color = [[(vietnameseSlangAppDelegate*)[[UIApplication sharedApplication] delegate] settings] objectForKey:@"theme"];
			return [color objectForKey:keyName];
		}
        
	}
}





@end
